SceneSortMethod
SceneSortMethod SortMethod
 
Parameters:

    SortMethod = The sort method, scene elements will be sorted with (0=Freq Sort, 1 = Quick Sort)
Returns: NONE
 

      SceneSortMethod sets the type of sorting that the scene cache should use.

     SortMethods

           0 = Freq Sort (default, good for large numbers of objects)
           1 = Quick Sort (normally better for smaller number of objects)




FACTS:


      * The items in the scene buffer are only sorted when rendering the scene from a camera.




Mini Tutorial:


      This example creates a camera, then each update it fills the scene with pixels and renders it. The user can toggle between the sorting methods with the space bar. Since there's a lot of items in the scene the freq sorting method should give the better performance


  
  
; Create camera 1.
  CreateCamera 1
  CameraCls 1,off
  
; max Z depth
  ZRange=5000
  
; perspective projection
  ProjectionX=300
  ProjectionY=300
  
  
; Start a Do/loop
  Do
     Cls RGB(0,0,0)
     
   ; Tell PB to capture the following GFX commands
   ; to the scene Buffer
     CaptureToScene
     ClsScene
     
   ; Get the camera X & Y position
     CamX=GetCameraX(1)
     CamY=GetCameraY(1)
     
     Randomize 056
     For lp=0 To 5000
        x=RndRange(-2000,2000)-CamX
        y=RndRange(-2000,2000)-CamY
        
        z=RndRange(1,Zrange)
        CaptureDepth z
      ; Draw a captured dot to the scenebuffer
        DotC 400+(x*ProjectionX)/z,300+(y*ProjectionY)/z,RndRGB()
     Next
     
     t=Timer()
     
   ; Draw the camera
     DrawCamera 1
     drawtime=Timer()-t
     
   ; check if the space key was pressed, if it
   ; was we toggle the scene sorting method
     If SpaceKey()
        SortMethod=1-SortMethod
        SceneSortMethod SortMethod
        FlushKeys
     EndIf
     
     
   ; display info about this demo
     Print "Space Bar to Change Sort Method"
     
     If SortMethod=0 Then t$="Freq"
     If SortMethod=1 Then t$="Quick"
     Print "Sort Method:"+T$
     Print "Draw Time:"+Str$(DrawTime)
     Print FPS()
     
     PositionCameraY 1,SinRadius(angle#,100)
     Angle#=WrapAngle(angle#,1)
     
     
     Sync
  Loop
  
  





 
Related Info: CameraBasics | CaptureToScene | ClsScene | CreateCamera | DrawCamera | SceneCacheSize :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com